package com.yicong.taxi.activity;

import android.Manifest;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.yicong.taxi.R;
import com.yicong.taxi.base.BaseActivity;
import com.yicong.taxi.iview.LoginView;
import com.yicong.taxi.model.MsgAuth;
import com.yicong.taxi.presenter.LoginPresenter;

import io.reactivex.functions.Consumer;

public class LoginActivity extends BaseActivity<LoginPresenter> implements LoginView {

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initPresenter() {
        presenter=new LoginPresenter(mActivity,this,this);
        presenter.init();
    }

    @Override
    public void initView() {
        RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA)
                .subscribe(new Consumer<Permission>() {
                    @Override public void accept(Permission permission) throws Exception {
                    }
                });

        EditText etAccount = findViewById(R.id.et_account);
        TextView tvSms = findViewById(R.id.tv_sms);
        findViewById(R.id.tv_send).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                presenter.sendMsg("2",etAccount.getText().toString().trim(),"您有一条验证码短信6846","易聪科技");
            }
        });
        findViewById(R.id.btn_register).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity,RegisterActivity.class));
            }
        });
    }

    @Override
    public void registerSuccess(MsgAuth msgAuth) {

    }
}
